﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace DIT.Domain
{
    public class FilingStatus : DomainBase
    {
        public readonly Guid AccountId;
        public readonly string AssessmentYear;
        public FilingStatus(Guid _accountId, string _assesmentYear)
        {
            if (_accountId == null)
                throw new ArgumentNullException("_accountId");
            if (_assesmentYear == null)
                throw new ArgumentNullException("_assesmentYear");

            AccountId = _accountId;
            AssessmentYear = _assesmentYear;
        }

        public FilingStatus(DataRow row)
            : this
            (
                new Guid(Convert.ToString(row["AccountId"])),
                row["AssessmentYear"] + string.Empty
            )
        {
            ID = new Guid(Convert.ToString(row["FilingStatusId"]));
            DesigOfficerWardorCircle = Convert.IsDBNull(row["DesigOfficerWardorCircle"]) ? null : row["DesigOfficerWardorCircle"] + string.Empty;
            ReturnFileSection = Convert.IsDBNull(row["ReturnFileSection"]) ? null : (ReturnFileSectionENUM?)Enum.Parse(typeof(ReturnFileSectionENUM), row["ReturnFileSection"] + string.Empty);
            AckNoOriginalReturn = Convert.IsDBNull(row["AckNoOriginalReturn"]) ? null : row["AckNoOriginalReturn"] + string.Empty;
            NoticeNo = Convert.IsDBNull(row["NoticeNo"]) ? null : row["NoticeNo"] + string.Empty;
            NoticeDate = Convert.IsDBNull(row["NoticeDate"]) ? null : (DateTime?)DateTime.Parse(row["NoticeDate"] + string.Empty);
            ReturnType = Convert.IsDBNull(row["ReturnType"]) ? null : (ReturnTypeENUM?)Enum.Parse(typeof(ReturnTypeENUM), row["ReturnType"] + string.Empty);
            RecieptNo = Convert.IsDBNull(row["RecieptNo"]) ? null : row["RecieptNo"] + string.Empty;
            OrigReturnFiledDate = Convert.IsDBNull(row["OrigReturnFiledDate"]) ? null : (DateTime?)DateTime.Parse(row["OrigReturnFiledDate"] + string.Empty);
            ResidentialStatus = Convert.IsDBNull(row["ResidentialStatus"]) ? null : (ResidentialStatusENUM?)Enum.Parse(typeof(ResidentialStatusENUM), row["ResidentialStatus"] + string.Empty);
            TaxStatus = Convert.IsDBNull(row["TaxStatus"]) ? null : (TaxStatusENUM?)Enum.Parse(typeof(TaxStatusENUM), row["TaxStatus"] + string.Empty);
            AsseseeRepFlag = Convert.IsDBNull(row["AsseseeRepFlag"]) ? null : (AsseseeRepFlagENUM?)Enum.Parse(typeof(AsseseeRepFlagENUM), row["AsseseeRepFlag"] + string.Empty);
            AsseseeRepName = Convert.IsDBNull(row["AsseseeRepName"]) ? null : row["AsseseeRepName"] + string.Empty;
            AsseseeRepAddress = Convert.IsDBNull(row["AsseseeRepAddress"]) ? null : row["AsseseeRepAddress"] + string.Empty;
            AsseseeRepPAN = Convert.IsDBNull(row["AsseseeRepPAN"]) ? null : row["AsseseeRepPAN"] + string.Empty;
        }

        public string DesigOfficerWardorCircle;
        public ReturnFileSectionENUM? ReturnFileSection;
        public string AckNoOriginalReturn;
        public string NoticeNo;
        public DateTime? NoticeDate;
        public ReturnTypeENUM? ReturnType;
        public string RecieptNo;
        public DateTime? OrigReturnFiledDate;
        public ResidentialStatusENUM? ResidentialStatus;
        public TaxStatusENUM? TaxStatus;
        public AsseseeRepFlagENUM? AsseseeRepFlag;
        public string AsseseeRepName;
        public string AsseseeRepAddress;
        public string AsseseeRepPAN;

        public static FilingStatus SampleFilingStatus(Account client, string assesmentYear)
        {
            return new FilingStatus(client.ID, assesmentYear)
            {
                DesigOfficerWardorCircle = "Ward1",
                ReturnFileSection = ReturnFileSectionENUM.US139_1,
                AckNoOriginalReturn = "ACK1",
                NoticeNo = "Notice1",
                NoticeDate = DateTime.Today,
                ReturnType = ReturnTypeENUM.Original,
                RecieptNo = "Reciept1",
                OrigReturnFiledDate = DateTime.Today,
                ResidentialStatus = ResidentialStatusENUM.RES,
                TaxStatus = TaxStatusENUM.TP,
                AsseseeRepFlag = AsseseeRepFlagENUM.Y,
                AsseseeRepName = "Bijit Kumar Gupta",
                AsseseeRepAddress = "Kolkata",
                AsseseeRepPAN = "APGPG6370Q"
            };
        }

        public static FilingStatus DefaultFilingStatus(Account client, string assesmentYear)
        {
            return new FilingStatus(client.ID, assesmentYear);
        }
    }
}
